﻿@model MealBooking.Core.Models.Orders.Order
@{
    var order = Model;
    Layout = "~/Views/Shared/_Layout.cshtml";
}
<!--Navbar-->
<div data-role="navbar" data-iconpos="left">
    <div class="float-left">
        <div data-role="controlgroup" data-type="horizontal" data-inset="true" data-mini="true"
            data-theme="c">
            @if (order.IsBooked)
            {
                <button data-role="button" data-icon="check" data-theme="a">
                    Booked By @order.Manager.Name</button>
            }
            else
            {
                <div class="ui-grid-a">
                    <div class="ui-block-a">
                        <a href="@Url.Action("EditTodayOrder")" data-icon="gear" data-role="button">Edit</a>
                    </div>
                    <div class="ui-block-b">
                        @using (Html.BeginForm("DeleteTodayOrder", "Order", FormMethod.Post))
                        {
                            <button type="submit" data-icon="delete" data-theme="e">
                                Delete</button>
                        }
                    </div>
                </div>
            }
        </div>
    </div>
    <div class="float-right">
        <div data-role="controlgroup" data-type="horizontal" data-inset="true" data-mini="true"
            data-theme="c">
            <a href="@Url.Action("CustomersTodayOrders")">Customers' Orders</a> <a href="@Url.Action("HistoryOrder")">
                History Orders</a>
        </div>
    </div>
</div>
<!--Navbar End-->
<ul data-role="listview" data-inset="true" data-mini="true">
    <li data-role="list-divider">Total Price : @order.TotalPrice</li>
    <li>
        <p>
            Last Update Time : @order.LastUpdateTime</p>
    </li>
    <li data-role="list-divider">Details: <span class="ui-li-count">@order.MealsWithSum.Sum(t => t.MealSum)</span>
    </li>
    @{
        var mealsWithSum = order.MealsWithSum;
        foreach (var mealWithSum in mealsWithSum)
        {
            double totalPrice = mealWithSum.Meal.Price * mealWithSum.MealSum;
        <li>
            <p>
                <strong>[@mealWithSum.MealSum Copy][@mealWithSum.Meal.Category.Name][@mealWithSum.Meal.ToString()]
                </strong>
            </p>
            <p>
                Total Price : @totalPrice [@mealWithSum.Meal.Price
                X @mealWithSum.MealSum]</p>
        </li>
        }        
    }
</ul>
@if (!order.IsOrdered)
{
    <ul data-role="listview" data-inset="true" data-mini="true">
        <li data-role="list-divider"></li>
        <li>
            @using (Html.BeginForm("OrderTodayOrder", "Order", FormMethod.Post))
            {
                <button type="submit">
                    Order It!</button>
            }
        </li>
    </ul>
}
